package org.ecpkn.PAGridSim.FastOptimizationWithoutSimulation.VoffVon;

import org.ecpkn.PAGridSim.core.gridsimEntity.paMachine.PAMachine;
import org.ecpkn.PAGridSim.core.tasksCreation.PeriodTaskCreator;

public class VoffVon {
	public static int getVaryNodeNumber(double workload) {
		int startNum = (int) workload + 1;
		int n = startNum;
		double fVaryOn;
		double fTry;
		do {
			fVaryOn = Math
					.pow(((n + 1) * (n + 1) * 1.0d / (2 * n * n + n)
							* PAMachine.POWERSTATIQUE / PAMachine.COEFFICIENT),
							1.0 / 3);
			fTry = workload / n * PeriodTaskCreator.STANDARDRATING;
			n = n + 1;
		} while (fTry > fVaryOn);

		int varyNum = n - 1;
		if (varyNum == 0) {
			varyNum = 1;
		}
		System.out.println("varyNum:"+varyNum);
		return varyNum;

	}

}
